#include<iostream>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<algorithm>
#include<map>
using namespace std;

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return a.second < b.second;
}

void solve()
{
	vector<pair<int, int>> ans;
	map<long long, int> ma;
	vector<long long> arr(1, 0);
	int n; cin >> n;
	for (int i = 1; i <= n; i++)
	{
		long long temp; cin >> temp;
		arr.push_back(arr.back() + temp);
	}
	ma[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (ma[arr[i]])
		{
			ans.push_back(pair<int, int>(ma[arr[i]], i));
		}
		ma[arr[i]] = i + 1;
	}
	sort(ans.begin(), ans.end(), cmp);
	int a = 0;
	int pre = -1;
	for (int i = 0; i < ans.size(); i++)
	{
		if (ans[i].first > pre)
		{
			a += 1;
			pre = ans[i].second;
		}
	}
	cout << a << endl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t; cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}
